package spring1.aspect;

import org.aopalliance.intercept.Joinpoint;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspectU {
    /*
    <aop:before method="myBefore" pointcut-ref="myPointcut"/>
     */
    @Before(value = "execution(* com.zzxy.spring1.service.impl.*.*(..))")
    public void myBefore(JoinPoint jp) {
       System.out.println("before method"+ jp.getSignature().getName());
        System.out.println("before ...");
    }

    public void myAfterReturning(JoinPoint jp,Object ret){
        System.out.println("after returning..."+ ret);
    }

    public Object myAround(ProceedingJoinPoint pjp) throws Throwable{
        System.out.println("around before...");
        Object obj = pjp.proceed();
        System.out.println("around before...");
        return obj;
    }

    public void myThrowable(Joinpoint jp,Throwable e){
        System.out.println("throwing.."+e.getMessage());
    }
    public void myAfter(JoinPoint jp) {
        System.out.println( jp.getSignature().getName());
        System.out.println("after ...");
    }
}
